package com.nnggstory.logs.logsocket;

import java.io.ObjectInputStream;

import org.apache.log4j.spi.LoggingEvent;

import ch.qos.logback.classic.spi.ILoggingEvent;

public class LogFactory {
	public static LogSLogModel createLog(ObjectInputStream ois) throws Exception {
		LogSLogModel model = new LogSLogModel();
		Object tempEvent = ois.readObject();
		ILoggingEvent logBackEvent = null;
		LoggingEvent log4jEvent = null;
		
		if(tempEvent instanceof ILoggingEvent) { // LogBack인경우
			logBackEvent = (ILoggingEvent) tempEvent;
			model.setLogsInfo(logBackEvent);
		} else if(tempEvent instanceof LoggingEvent) { // Log4J인경우
			log4jEvent = (LoggingEvent) tempEvent;
			model.setLogsInfo(log4jEvent);
		}
		return model;
	}
}
